<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>注册</title>
<%@ include file="/WEB-INF/views/include.inc.jsp"%>
<link rel="stylesheet" href="${contextPath }/styles/bootstrapvalidator/css/bootstrapValidator.css"/>
<script src="${contextPath }/styles/bootstrapvalidator/js/bootstrapValidator.js"></script>
<script src="${contextPath }/styles/bootstrapvalidator/js/language/zh_CN.js"></script>
</head>
<body class="page-login">
<div class="container">
  <form class="form-login" method="post" action="${contextPath }/index/registered" onsubmit="return onSubmit(this, callback);">
    <h2 class="form-login-heading"></h2>
    <div class="form-group">
      <input type="text" name="username" class="form-control" placeholder="用户名" autofocus>
      <span class="glyphicon icon-name" aria-hidden="true"></span>
    </div>
    <div class="form-group">
      <input type="password" name="password" class="form-control" placeholder="密&nbsp;&nbsp;&nbsp;码">
      <span class="glyphicon icon-pwd" aria-hidden="true"></span>
    </div>
    <div class="form-group">
      <input type="text" name="tel" class="form-control" placeholder="手机号" autofocus>
      <span class="glyphicon icon-phone" aria-hidden="true"></span>
    </div>
    <div class="form-group">
      <button class="btn btn btn-info btn-block btn-submit" type="submit">注&nbsp;&nbsp;册</button>
    </div>
    <p class="addition"><a href="${contextPath }/login" class="pull-right">已有账号</a></p>
  </form>
</div>
</body>
<script>
function success(msg) {
	bootbox.alert(msg, function(result){
		goToPage("${contextPath}/login");
	});
}
$(function() {
	if ("${msg}".length > 0) {
		error("${msg}");
	}
	$('form').bootstrapValidator({
		message: 'This value is not valid',
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		},
		fields: {
			username: {
				message: '用户名验证失败',
				validators: {
					notEmpty: {
						message: '用户名不能为空'
					},
                    stringLength: {
                        min: 2,
                        max: 8,
                        message: '用户名(2-8字符)'
                    }
				}
			},
			password: {
				validators: {
					notEmpty: {
						message: '密码不能为空'
					},
                    stringLength: {
                        min: 6,
                        max: 10,
                        message: '密码(6-10字符)'
                    }
				}
			},
			tel: {
				validators: {
					regexp: {
						regexp: /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/,
						message: '手机号不合法'
					}
				}
			}
		}
	});
});
</script>
</html>
